package com.advaita.util;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;

public class ComboListener implements ActionListener {
	JComboBox combo;

	Object currentItem;

	public ComboListener(JComboBox combo) {
		this.combo = combo;
		combo.setSelectedIndex(0);
		currentItem = combo.getSelectedItem();
	}

	public void actionPerformed(ActionEvent e) {
		Object tempItem = combo.getSelectedItem();
		if (!((CanEnable) tempItem).isEnabled()) {
			combo.setSelectedItem(currentItem);
		} else {
			currentItem = tempItem;
		}
	}
}
